package com.beans;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2022-10-02
 * Time: 11:27
 */

//Bean将一个类型的对象注入多次

@Controller
public class ManyController {

    @Autowired
    @Qualifier("user1") //User类中注入了多次Bean 淡出使用一个@Autowired注入是会报错的
    //解决办法是 添加以下属性的其中一种 重命名
    //@Resource(name = "user2")
    private User user;

    public void sayHi(){
        System.out.println("User -> | " + user);
    }
}
